/*
 * @(#)Mp3File.java
 * 
 * Copyright(C) 2004 Yujin Kim
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.netexplode.jtunes.model.media;

import java.io.File;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <code>Mp3File</code> represents .....
 * 
 * @author ykim
 * @version $Revision: 1.2 $
 * @since 0.1
 */
public class Mp3File implements MediaFile {

	private static final Log log = LogFactory.getLog(Mp3File.class);

	private File file;

	private Tag tag;

	private Metadata metadata;

	public Mp3File(File location) throws Exception {
		this.file = location;
		this.tag = Id3Tag.getId3Tag(file);
	}

	public File getFile() {
		return this.file;
	}

	public Tag getTag() {
		return this.tag;
	}

	public Metadata getMetadata() {
		return this.metadata;
	}

	public String getFormat() {
		if (this.file != null) {
			String filename = this.file.getName();
			log.info("format " + filename.substring(filename.lastIndexOf(".") + 1));
			return filename.substring(filename.lastIndexOf(".") + 1);
		}
		return null;
	}
}